package cn.ekuma.epos.datalogic.define.dao.erp.ordercalc;

import cn.ekuma.data.dao.ModifiedLogDAO;

import com.openbravo.bean.erp.ordercalc.OrderCalcItem;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class OrderCalcItemDAO  extends ModifiedLogDAO<OrderCalcItem>{

    public OrderCalcItemDAO(I_Session s) {
		super(s);
	}

	@Override
    public TableDefinition getTable() {
        return new TableDefinition(s,
                  "ORDERCALCITEM",
                  new Field[]{
                       new Field("ID",Datas.STRING,Formats.STRING),
                       new Field("ORDERID",Datas.STRING,Formats.STRING),
                       new Field("ORDERCALCID",Datas.STRING,Formats.STRING),
                       new Field("ORDERCALCITEMNAME",Datas.STRING,Formats.STRING),
                       new Field("TOTALPRICE",Datas.DOUBLE,Formats.DOUBLE),
                       new Field("LASTMODIFIED",Datas.TIMESTAMP, Formats.TIMESTAMP)
                      
                  },new int[]{0});
    }

	@Override
	public void writeInsertValues(DataWrite dp, OrderCalcItem obj)
			throws BasicException {
          dp.setString(1,obj.getId());
          dp.setString(2,obj.getOrderId());
          dp.setString(3,obj.getOrderCalcId());
          dp.setString(4,obj.getOrderCalcName());
          dp.setDouble(5,obj.getTotalPrice());
          dp.setTimestamp(6,obj.getLastModified());
	}

	@Override
	public Class getSuportClass() {
		return OrderCalcItem.class;
	}

	@Override
	public OrderCalcItem readValues(DataRead dr, OrderCalcItem obj)
			throws BasicException {
		if(obj==null)
			obj=new OrderCalcItem();
		obj.setId(dr.getString(1));
		obj.setOrderId(dr.getString(2));
		obj.setOrderCalcId(dr.getString(3));
		obj.setOrderCalcName(dr.getString(4));
		obj.setTotalPrice(dr.getDouble(5));
		obj.setLastModified(dr.getTimestamp(6));
		return obj;
	}
}
